<?php
	
	require_once 'lib/classes/jspeed.class.php';
	
	//$script = file_get_contents('js/test2.js');
	
	if (isset($_POST['go'])) {
		$script = isset($_POST['pre']) ? stripslashes($_POST['pre']) : '';
		
		$minify = isset($_POST['minify']) && $_POST['minify'] == 1;
		$engine = new JSpeed($script, $minify);
		$engine->optimize();
	
		$pre = $engine->pre[0];
		$post = $engine->post[0];
	}
?>
<html>
	<head>
		<title>JSpeed Test</title>
	</head>
	<link rel="stylesheet" href="css/styles.css" type="text/css" />
	<body>
		<div class="container" align="center">
			<h1>JSpeed</h1>
			<form method="post" action="">
				<fieldset>
					<h2>Your Original JavaScript:</h2>
					<textarea name="pre"><?php echo $pre ?></textarea>
				</fieldset>
				<fieldset>
					<h2>Optimized JavaScript:</h2>
					<textarea name="post"><?php echo $post ?></textarea>
				</fieldset>
				<fieldset>
					<h3>Options</h3>
					<label>Minify?</label> <input type="checkbox" name="minify" value="1"<?php echo $minify ? ' checked' : '' ?> /><br/>
					<div id="results"></div>
				</fieldset>
				<fieldset>
					<input type="submit" name="go" value="Go JSpeed, Go!" />
				</fieldset>
			</form>
		</div>
		<?php $engine->benchmark('results'); ?>
	</body>
</html>